package org.ns.summer.example;

import org.apache.ibatis.annotations.*;

public interface UserAmountMapper {

    @Update("update userAmount set money=money+#{money} where userId = #{userId}")
    Integer addMoney(@Param("userId") long userId, @Param("money") long money);

    @Update("update userAmount set money=money-#{money} where userId = #{userId}")
    Integer subMoney(@Param("userId") long userId, @Param("money") long money);

    @Insert("insert into userAmount (userId, money) values (#{userId}, #{money})")
    Integer insert(@Param("userId") long userId, @Param("money") long money);

    @Delete("delete from userAmount where userId = #{userId}")
    Integer delete(@Param("userId") long userId);

    @Select("select money from userAmount where userId = #{userId}")
    Long getMoney(@Param("userId") long userId);
}
